package com.yequan.thread.threadpool.mythreadpoolmanager;


/**
 * @author yequan
 * @date 2019/12/02
 */
public class TestCustomThreadPoolManager {

    public static void main(String[] args) throws InterruptedException {

        CustomThreadPoolManager cpuIntensiveThreadPoolManager = ThreadPoolManagerFactory.newCpuIntensiveThreadPoolManager();
        CustomThreadPoolManager ioIntensiveThreadPoolManager = ThreadPoolManagerFactory.newIoIntensiveThreadPoolManager();
        CustomThreadPoolManager singleThreadPoolManager = ThreadPoolManagerFactory.newSingleThreadPoolManager();

        System.out.println(cpuIntensiveThreadPoolManager.getCorePoolCount() + " - " + ioIntensiveThreadPoolManager.getCorePoolCount()
                + " - " + singleThreadPoolManager.getCorePoolCount());


        for (int i = 0; i < 15; i++) {
            int taskId = i;
            Runnable task = new Runnable() {
                @Override
                public void run() {
                    System.out.println("任务来了: " + taskId);
                }
            };
            long taskCount = cpuIntensiveThreadPoolManager.getTaskCount();
            System.err.println("taskCount:  " + taskCount);
            cpuIntensiveThreadPoolManager.addExecuteTask(task);
        }
        Thread.sleep(3000);
        long taskCount = cpuIntensiveThreadPoolManager.getTaskCount();
        System.err.println("taskCount:  " + taskCount);
    }

}
